<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新后台管理员信息表</title>
</head>
<body>
<form>
    <table border="1">
        <tr><td colspan="2"><h1>更新后台管理员信息表内容</h1></td></tr>
        <tr>
            <td>后台管理员ID</td>
            <td>
                    <span id="adminId_txt"></span><input type="hidden" id="adminId" name="adminId"/>
            </td>
        </tr>
        <tr>
            <td>登录名</td>
            <td>
                    <input type="text" id="loginName" name="loginName"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                    <input type="text" id="password" name="password"/>
            </td>
        </tr>
        <tr>
            <td>用户真实姓名</td>
            <td>
                    <input type="text" id="adminName" name="adminName"/>
            </td>
        </tr>
        <tr>
            <td>证件号码</td>
            <td>
                    <input type="text" id="identityCardNo" name="identityCardNo"/>
            </td>
        </tr>
        <tr>
            <td>手机号</td>
            <td>
                    <input type="text" id="mobilePhone" name="mobilePhone"/>
            </td>
        </tr>
        <tr>
            <td>邮箱</td>
            <td>
                    <input type="text" id="adminEmail" name="adminEmail"/>
            </td>
        </tr>
        <tr>
            <td>会员生日</td>
            <td>
                    <input type="text" id="birthday" name="birthday"/>
            </td>
        </tr>
        <tr>
            <td>用户类型</td>
            <td>
                    <input type="text" id="type" name="type"/>
            </td>
        </tr>
        <tr>
            <td>负责区域</td>
            <td>
                    <input type="text" id="responsible" name="responsible"/>
            </td>
        </tr>
        <tr>
            <td>最后修改时间</td>
            <td>
                    <input type="text" id="modifiedTime" name="modifiedTime"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other1" name="other1"/>
            </td>
        </tr>
        <tr>
            <td>其他</td>
            <td>
                    <input type="text" id="other2" name="other2"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" id="tijiao" value="提交"/>
                <input type="reset" value="重置"/>
            </td>
        </tr>
    </table>
</form>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    var param = location.href.substring(location.href.indexOf('?')+1);
    $.getJSON("/admin/findById.json",param,function(detail){
        $("#adminId_txt").text(detail.adminId);
        $("#adminId").val(detail.adminId);
        $("#loginName").val(detail.loginName);
        $("#password").val(detail.password);
        $("#adminName").val(detail.adminName);
        $("#identityCardNo").val(detail.identityCardNo);
        $("#mobilePhone").val(detail.mobilePhone);
        $("#adminEmail").val(detail.adminEmail);
        $("#birthday").val(detail.birthday);
        $("#type").val(detail.type);
        $("#responsible").val(detail.responsible);
        $("#modifiedTime").val(detail.modifiedTime);
        $("#other1").val(detail.other1);
        $("#other2").val(detail.other2);
    });
    //点击提交按钮
    $("#tijiao").click(function(){
        if(!$("#loginName").val()){
            alert("登录名不能为空");
            return;
        }
        if(!$("#password").val()){
            alert("密码不能为空");
            return;
        }
        if(!$("#adminName").val()){
            alert("用户真实姓名不能为空");
            return;
        }
        if(!$("#identityCardNo").val()){
            alert("证件号码不能为空");
            return;
        }
        if(!$("#mobilePhone").val()){
            alert("手机号不能为空");
            return;
        }
        if(!$("#adminEmail").val()){
            alert("邮箱不能为空");
            return;
        }
        if(!$("#birthday").val()){
            alert("会员生日不能为空");
            return;
        }
        if(!$("#type").val()){
            alert("用户类型不能为空");
            return;
        }
        if(!$("#responsible").val()){
            alert("负责区域不能为空");
            return;
        }
        if(!$("#modifiedTime").val()){
            alert("最后修改时间不能为空");
            return;
        }

        
        $.post("/admin/update.json",$("form").serialize(),function(result){
            if(result.flag==true){
                alert(result.msg);
                location.href="/admin/admin/list.html";
            }else{
                alert(result.msg);
            }
        })

    })
</script>

</body>
</html>